
********************************************************************************
*********              4.   EUKLEMS                                 ***************
********************************************************************************

** ICT data is on NACErev2 2-digit level


********************************************************************************
*****    4.1  aggregate employment data to level of EUKLEMS      ***************
********************************************************************************
use $data/bhp_employment_r_s_y_NACErev2_2d_1994.dta, clear
rename nace2_2d nace_rev2
merge m:1 nace_rev2 using $orig/crosswalk_euklems_to_nace2
/* nace2_2d == 98 or 99 not matched --> other categories, good */

collapse (sum) employees_kreis_euklems_code = employment_r_s_y (sum) n_establishments, by(year region code)


*** calculate share of industry workers in given Kreis
egen employees_in_sector = sum(employees_kreis_euklems_code), by(year code)
gen kreis_share_of_sector = employees_kreis_euklems_code / employees_in_sector
sort year code region


*** remove years prior to 1994 (note that for 1994, we use values from 1995)
drop if year < 1995


**** merge on ICT data
merge m:1 code year using $orig/EUKLEMS_DE.dta
drop if _merge != 3
drop _merge


merge m:1 code year using $orig/EUKLEMS_EU_non_DE.dta
drop if _merge != 3
drop _merge

********************************************************************************
*****             4.3 aggregate ICT data to Kreis level          ***************
********************************************************************************

*** Calculate share of ICT attributed to region
gen ICT_total_s_k = ICT_total * kreis_share_of_sector
gen ICT_eu_total_s_k = ICT_eu_total * kreis_share_of_sector

*** Sum up ICT per region
collapse (sum) ICT_total_k = ICT_total_s_k (sum) ///
	ICT_eu_total_k = ICT_eu_total_s_k ///
	(sum) n_establishments, by(region year)


*** check underlying number of establishments and employees
count if n_establishments <= 20

rename n_establishments n_ICT

label var ICT_total_k "total ICT capital stock, based on German ICT data"
label var ICT_eu_total_k "total ICT capital stock, based on EU (non-DE) data"
label var n_ICT "number of establishments underlying the agggregation"
save $data/ICT_kreis.dta, replace












